<template>
	<view>
		<view class="order-info">
			<view class="item-a">下单时间：{{orderInfo.createdStamp}}</view>
			<view class="item-b">订单编号：{{orderInfo.orderId}}</view>
			<!-- <view class="item-c">
				<view class="l">实付：<text class="cost">￥{{orderInfo.grandTotal}}</text></view> -->
				<!-- <view class="r">
					<view class="btn" @click="cancelOrder">取消订单</view>
					<view class="btn active" @click="payOrder">去付款</view>
				</view> -->
			<!-- </view> -->
		</view>
		<view class="order-goods">
			<view class="h">
				<view class="label">商品信息</view>
				<!-- <view class="status">{{orderInfo.productFeatureDesc}}</view> -->
			</view>
			<view class="goods">
				<view class="item" v-for="(item, index) of orderInfo.orderItems" :key="item.orderItemSeqId" :data-index="index">
					<view class="img">
						<image :src="orderInfo.baseUrl + item.originalImageUrl" />
					</view>
					<view class="info">
						<view class="t">
							<text class="name uni-ellipsis">{{item.productName}}</text>
							<text class="number">x{{item.quantity}}</text>
						</view>
						<view class="attr" v-if="item.productFeatureApplDesc !== undefined">{{item.productFeatureApplDesc}}</view>
						<view class="price">￥{{item.unitListPrice}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="order-bottom">
			<view class="address">
				<view class="t">
					<text class="name" v-if="orderInfo.orderContactMech !== undefined">{{orderInfo.orderContactMech.toName}}</text>
					<text class="mobile" v-if="orderInfo.orderContactMech !== undefined">{{orderInfo.orderContactMech.contactNumber}}</text>
				</view>
				<view class="b">{{orderInfo.address}}</view>
			</view>
			<view class="total">
				<view class="t">
					<text class="label">商品合计：</text>
					<text class="txt">￥{{orderInfo.grandTotal}}</text>
				</view>
				<view class="t" v-if="orderInfo.deliverPrice !== undefined">
					<text class="label">运费：</text>
					<text class="txt">￥{{orderInfo.deliverPrice}}</text>
				</view>
			</view>
			<view class="pay-fee">
				<text class="label">实付：</text>
				<text class="txt">￥{{orderInfo.grandTotal}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations,
		mapGetters
	} from 'vuex'
	
	import {getOrder} from '@/api/buy/order'

	export default {
		data() {
			return {
				orderInfo: {
					
				}
			}
			
		},
		onLoad(e) {
			this.loadOrder(e.id)
		},
		methods: {
			loadOrder(orderId) {
				getOrder(orderId).then(response => {
					console.log(JSON.stringify(response))
					if(response.status == 200 && response.rel == true) {
						this.orderInfo = response.data;
					} else {
						uni.showModal({
							title: '',
							content: '没有找到订单详细信息，确定要返回吗？',
							success: async function(res) {
								if (res.confirm) {
									uni.navigateBack()
								}
							}
						})
					}
				});
			},
			
		}
	}
</script>

<style>
	.order-info {
		padding-top: 25upx;
		background: #fff;
		height: auto;
		overflow: hidden;
		width: 750upx;
	}

	.item-a {
		padding-left: 31.25upx;
		height: 42.5upx;
		padding-bottom: 12.5upx;
		line-height: 30upx;
		font-size: 30upx;
		color: #666;
	}

	.item-b {
		padding-left: 31.25upx;
		height: 29upx;
		line-height: 29upx;
		margin-top: 12.5upx;
		margin-bottom: 41.5upx;
		font-size: 30upx;
		color: #666;
	}

	.item-c {
		margin-left: 31.25upx;
		border-top: 1px solid #f4f4f4;
		height: 103upx;
		line-height: 103upx;
	}

	.item-c .l {
		float: left;
	}

	.item-c .r {
		height: 103upx;
		float: right;
		display: flex;
		align-items: center;
		padding-right: 16upx;
	}

	.item-c .r .btn {
		float: right;
	}

	.item-c .cost {
		color: #b4282d;
	}

	.item-c .btn {
		line-height: 66upx;
		border-radius: 5upx;
		text-align: center;
		margin: 0 15upx;
		padding: 0 20upx;
		height: 66upx;
	}

	.item-c .btn.active {
		background: #b4282d;
		color: #fff;
	}

	.order-goods {
		margin-top: 20upx;
		background: #fff;
		width: 100%;
	}

	.order-goods .h {
		height: 93.75upx;
		line-height: 93.75upx;
		margin-left: 31.25upx;
		border-bottom: 1px solid #f4f4f4;
		padding-right: 31.25upx;
	}

	.order-goods .h .label {
		float: left;
		font-size: 30upx;
		color: #333;
	}

	.order-goods .h .status {
		float: right;
		font-size: 30upx;
		color: #b4282d;
	}

	.order-goods .item {
		display: flex;
		align-items: center;
		height: 192upx;
		margin-left: 31.25upx;
		padding-right: 31.25upx;
		border-bottom: 1px solid #f4f4f4;
	}

	.order-goods .item:last-child {
		border-bottom: none;
	}

	.order-goods .item .img {
		height: 145.83upx;
		width: 145.83upx;
		background: #f4f4f4;
	}

	.order-goods .item .img image {
		height: 145.83upx;
		width: 145.83upx;
	}

	.order-goods .item .info {
		flex: 1;
		height: 145.83upx;
		margin-left: 20upx;
	}

	.order-goods .item .t {
		margin-top: 8upx;
		height: 33upx;
		line-height: 33upx;
		margin-bottom: 10.5upx;
	}

	.order-goods .item .t .name {
		display: block;
		float: left;
		height: 33upx;
		line-height: 33upx;
		color: #333;
		font-size: 30upx;
	}

	.order-goods .item .t .number {
		display: block;
		float: right;
		height: 33upx;
		text-align: right;
		line-height: 33upx;
		color: #333;
		font-size: 30upx;
	}

	.order-goods .item .attr {
		height: 29upx;
		line-height: 29upx;
		color: #666;
		margin-bottom: 25upx;
		font-size: 25upx;
	}

	.order-goods .item .price {
		height: 30upx;
		line-height: 30upx;
		color: #333;
		font-size: 30upx;
	}

	.order-bottom {
		margin-top: 20upx;
		padding-left: 31.25upx;
		height: auto;
		overflow: hidden;
		background: #fff;
		width: 718.75upx;
	}

	.order-bottom .address {
		height: 128upx;
		padding-top: 25upx;
		border-bottom: 1px solid #f4f4f4;
	}

	.order-bottom .address .t {
		height: 35upx;
		line-height: 35upx;
		margin-bottom: 7.5upx;
	}

	.order-bottom .address .name {
		display: inline-block;
		height: 35upx;
		width: 140upx;
		line-height: 35upx;
		font-size: 25upx;
	}

	.order-bottom .address .mobile {
		display: inline-block;
		height: 35upx;
		line-height: 35upx;
		font-size: 25upx;
	}

	.order-bottom .address .b {
		height: 35upx;
		line-height: 35upx;
		font-size: 25upx;
	}

	.order-bottom .total {
		height: 106upx;
		padding-top: 20upx;
		border-bottom: 1px solid #f4f4f4;
	}

	.order-bottom .total .t {
		height: 25upx;
		line-height: 25upx;
		margin-bottom: 7.5upx;
		display: flex;
	}

	.order-bottom .total .label {
		width: 140upx;
		display: inline-block;
		height: 35upx;
		line-height: 35upx;
		font-size: 25upx;
	}

	.order-bottom .total .txt {
		flex: 1;
		display: inline-block;
		height: 35upx;
		line-height: 35upx;
		font-size: 25upx;
	}

	.order-bottom .pay-fee {
		height: 81upx;
		line-height: 81upx;
	}

	.order-bottom .pay-fee .label {
		display: inline-block;
		width: 140upx;
		color: #b4282d;
	}

	.order-bottom .pay-fee .txt {
		display: inline-block;
		width: 140upx;
		color: #b4282d;
	}
</style>
